﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;

namespace TJXAppliction
{
    public partial class MainForm : DevExpress.XtraBars.Ribbon.RibbonForm
    {

        private DataSet MenuTreeDs;
        public MainForm()
        {
            InitializeComponent();
            initTreeMenu();
            //Test();
        }

        void initTreeMenu()
        {
            MenuTreeDs = DBMgr.DbHelperOra.Query("select   lpad(t.统计项编号,length(t.统计项编号)-2 ,'0') as  ParentID,t.统计项编号 as ID, t.统计项名称,t.执行语句,t.是否显示,t.执行状态,t.类型,t.结果,t.统计描述,t.连接参数编号,t.连接参数 from v_tj_tjx t");
           treeList1.DataSource = MenuTreeDs.Tables[0].DefaultView;
        }


        void Test(GridConfig config)
        {
            GridForm form = new GridForm(config);
            form.MdiParent = this;
            form.Show();

        }

        private void barStaticItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            saveFileDialog1.ShowDialog();

            (xtraTabbedMdiManager1.SelectedPage.MdiChild as GridForm).Text = "开始生成XML";
            (xtraTabbedMdiManager1.SelectedPage.MdiChild as GridForm).WriteFileXML(saveFileDialog1.FileName);
        }

        private void treeList1_DoubleClick(object sender, EventArgs e)
        {
            DevExpress.XtraTreeList.Nodes.TreeListNode node = treeList1.FocusedNode;
            GridConfig config=new GridConfig();
            config.统计项名称 = node.GetValue("统计项名称").ToString();
            config.执行语句 = node.GetValue("执行语句").ToString();
            Test(config);
        }
    }
}